class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        r = 0
        if x == 0:
            x = x
        else:
            if x > (2 ** 31) - 1 or x < 2 ** -31:
                return 0
            else:
                r = r * 10 + x % 10
                x = x // 10
                return x

def main():
    x = int(input('x = '))
    x_rev = Solution().reverse(x)
    print(x_rev)

if __name__ == '__main__':
    main()
